package com.example.lol.ui;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.lol.R;
import com.example.lol.ui.adapter.NewsAdapter;
import com.example.lol.ui.adapter.NewsAdapter2;
import com.example.lol.ui.bean.NewBean;
import com.example.lol.ui.bean.NewBean2;

import java.util.ArrayList;
import java.util.List;

public class SecondHomeFragment extends Fragment {
    private String[] title = new String[]{"          TES 2:0 BLG knight发条大招冲击波拉到4人",
            "   FPX 2：0 LGD三线压制吃满15层镀层",
            "   LOL春季赛3月9日首发名单，Lwx、Krammer下路交锋",
            "   新忍村大战————IGvsTES复盘",
            "   小蜜蜂宝典————永久皮肤宝箱重开功能上线"
    };
    private String[] title1 = new String[]{" 英雄联盟官方赛事 ",
            "英雄联盟官方",
            "英雄联盟官方",
            "英雄联盟官方",
            "英雄联盟官方"
    };
    private int[] cover = new int[]{R.drawable.ic_tes,
            R.drawable.ic_fpx,
            R.drawable.ic_fpx_2,
            R.drawable.ic_ig,
            R.drawable.ic_xmf};
    private String[] number = new String[]{"22","13","19","202","555"};
    private List<NewBean2> initData() {
        List<NewBean2> list = new ArrayList<>();
        list.add(new NewBean2());
        list.add(new NewBean2(title[0],title1[0],cover[0],R.drawable.ic_lol_icon,R.drawable.ic_chat,number[0],3));
       for (int i=1;i<5;i++){
           list.add(new NewBean2(title[i % title.length],title1[i % title1.length],cover[i % cover.length],R.drawable.ic_lol_icon,R.drawable.ic_chat,number[i %number.length],2));
       }
        return list;
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.recycle, container, false);
        RecyclerView textView = view.findViewById(R.id.recycle_ss);
        textView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        NewsAdapter2 newsAdapter=new NewsAdapter2(initData());
        newsAdapter.setList(initData());
        textView.setAdapter(newsAdapter);
        return view;
    }
}